local fuyu = fk.CreateSkill{
  name = "wk_heg__fuyu",
}

Fk:loadTranslationTable{
  ["wk_heg__fuyu"] = "伏御",
  [":wk_heg__fuyu"] = "当你响应其他势力角色使用的牌后，你可令其横置，若其已横置，则改为你对其造成1点伤害。",

  ["$wk_heg__fuyu1"] = "御敌之策，成竹于胸。",
  ["$wk_heg__fuyu2"] = "以缓制急，不战屈兵。",
}

local H = require "packages/ol_hegemony/util"

fuyu:addEffect(fk.CardUseFinished, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and data.responseToEvent and data.responseToEvent.card
      and (data.responseToEvent.card:isCommonTrick() or data.responseToEvent.card.type == Card.TypeBasic)
      and not H.compareKingdomWith(data.responseToEvent.from, player)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = data.responseToEvent.from
    if to.dead then return end
    if not to.chained then
      to:setChainState(true)
    else
      room:damage{
        from = player,
        to = to,
        damage = 1,
        skillName = fuyu.name,
      }
    end
  end,
})

fuyu:addEffect(fk.CardRespondFinished, {
  can_trigger = function(self, event, target, player, data)
  return player:hasSkill(self) and target == player and data.responseToEvent and data.responseToEvent.card 
    and (data.responseToEvent.card:isCommonTrick() or data.responseToEvent.card.type == Card.TypeBasic)
    and not H.compareKingdomWith(data.responseToEvent.from, player)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = data.responseToEvent.from
    if to.dead then return end
    if not to.chained then
      to:setChainState(true)
    else
      room:damage{
        from = player,
        to = to,
        damage = 1,
        skillName = fuyu.name,
      }
    end
  end,
})

return fuyu
